package org.example.controller;

import org.example.model.User;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: huang
 * @Date: 2021/8/26 10:47
 * @Description:
 */
@RestController
@RequestMapping("/rest")
public class TestResTController {
    @GetMapping("/1")
    public Object r1() {
        Map<String,Object> map = new HashMap<>();
        map.put("username","wang");
        map.put("age",22);
        return  map;
    }
    @PostMapping("/2")
    public Object r2() {
        Map<String,Object> map = new HashMap<>();
        map.put("username","huang");
        map.put("age",22);
        return  map;
    }

    @GetMapping("/user/{id}")
    public Object r3(@PathVariable Integer id) {
        Map<String,Object> map = new HashMap<>();
        map.put("username","huang: "+ id);
        map.put("age",22);
        return  map;
    }

    @PostMapping("/3")
    public Object r3(@RequestParam String username,
                     @RequestParam String password) {
        Map<String,Object> map = new HashMap<>();
        map.put("用户名", username);
        map.put("密码",password);
        return  map;
    }

    @PostMapping("/4")
    public Object r4(User user) {
        Map<String,Object> map = new HashMap<>();
        map.put("用户名", user.getUsername());
        map.put("密码",user.getPassword());
        return  map;
    }

}
